﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Quotes.ascx.cs" Inherits="ERP.Modules.Quotes" %>
<script type="text/javascript">
    var indMoney = function (v) {
        v = (Math.round((v - 0) * 100)) / 100;
        v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
        v = String(v);
        var ps = v.split('.'),
            whole = ps[0],
            sub = ps[1] ? '.' + ps[1] : '.00',
            r = /(\d+)(\d{3})/;
        while (r.test(whole)) {
            whole = whole.replace(r, '$1' + ',' + '$2');
        }
        v = whole;

        return v;
    };
    var NumCheck = function () {
        var x = window.App.txtSumPrice.getValue();
        var y = window.App.txtSumVAT.getValue();
        var k = window.App.txtShippingFee.getValue();
        var z = parseFloat(x.replace(/[,]/g, "")) + parseFloat(y.replace(/[,]/g, "")) + parseFloat(k.replace(/[,]/g, ""));
        window.App.txtSumTotalCash.setValue(z);
        window.App.txtShippingFee.setValue(FormatNumber(k));
    };
</script>
<%-------------------------------%>
<ext:Hidden ID="FormatTypeQuotes" runat="server" />
<ext:Panel runat="server" Layout="Fit" Border="False" ID="PanelQuotes">
    <Content>
        <%--------------GridQuotes-----------------%>
        <ext:GridPanel
            ID="grQuotes"
            Cls="grid-double"
            runat="server"
            EnableColumnMove="true"
            Border="False">
            <%-------------StoreQuotes-----------------%>
            <Store>
                <ext:Store
                    ID="StoreQuotes"
                    runat="server"
                    OnReadData="StoreQuotes_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model ID="ModelQuotes" runat="server" IDProperty="Quotes_ID">
                            <Fields>
                                <ext:ModelField Name="Quotes_No" Type="String" />
                                <ext:ModelField Name="Quotes_Name" Type="String" />
                                <ext:ModelField Name="Quotes_Time" Type="Date" />
                                <ext:ModelField Name="Customer_Alias" Type="String" />
                                <ext:ModelField Name="Customer_Name" Type="String" />
                                <ext:ModelField Name="Quotes_Note" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" Width="30" Align="Center" />
                    <ext:DateColumn ID="Column2" runat="server" Text="Ngày báo giá" Width="100" DataIndex="Quotes_Time" Format="dd-MM-yyyy"></ext:DateColumn>
                    <ext:Column ID="Column3" runat="server" Text="Số báo giá" Width="150" DataIndex="Quotes_No"></ext:Column>
                    <ext:Column ID="Column7" runat="server" Text="Mã khách hàng" Width="90" DataIndex="Customer_Alias"></ext:Column>
                    <ext:Column ID="Column4" runat="server" Text="Tên khách hàng" Width="100" DataIndex="Customer_Name" Flex="1"></ext:Column>
                </Columns>
            </ColumnModel>
            <DirectEvents>
                <ItemDblClick OnEvent="QuotesDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="Quotes_ID" Value="record.data.Quotes_ID" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel ID="CheckboxSelectionModelQuotes" runat="server" Mode="Multi">
                    <Listeners>
                       <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                   </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <DockedItems>
                <ext:Toolbar ID="ToolbarTopMain" runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grQuotes}, #{FormatTypeQuotes}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>

                    </Items>
                </ext:Toolbar>
                <ext:Toolbar ID="ToolbarPagging" runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event"></TriggerClick>
                                <KeyPress OnEvent="Search_Event"></KeyPress>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar ID="PagingToolbarQuotes" runat="server" StoreID="StoreQuotes" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <%-----------WindowsQuotes-----------------%>
        <ext:Window ID="WindowsQuotes" runat="server"
            Title="Cập nhật báo giá"
            DefaultAnchor="100%"
            Width="832px"
            Height="531px"
            Hidden="true"
            AutoScroll="False"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="false"
            Modal="true"
            HideMode="Offsets"
            Border="false"
            Padding="5"
            DefaultButton="btnSavePopUp">
            <Items>
                <ext:Toolbar ID="ToolbarQuotes" runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelQuotes}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="Quotes_Provision" Value="Ext.encode(#{grQuotesProvision}.getRowsValues())" Mode="Raw" />
                                    </ExtraParams>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button runat="server" Text="Thêm sản phẩm" Icon="Add" ID="btnAddProduct">
                            <DirectEvents>
                                <Click OnEvent="btnAddQuotesMaterials_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button ID="btnDeleteProduct" runat="server" Text="Xoá sản phẩm" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDelProduct_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá sản phẩm này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:TextField ID="txtQuotes_ID" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                    </Items>
                </ext:Toolbar>
                <ext:FormPanel ID="FormPanelQuotes" runat="server"
                    BodyPadding="10"
                    Frame="true"
                    DefaultAnchor="100%">
                    <Items>
                        <ext:FieldContainer ID="FieldContainer1"
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtQuotes_No" runat="server" FieldLabel="Mã báo giá:" AllowBlank="false" Width="250" Margins="0 20 0 0" />
                                <ext:DateField ID="txtQuotes_Time" runat="server" FieldLabel="Ngày báo giá:" AllowBlank="false" Width="250" />
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer ID="FieldContainer2"
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:Hidden runat="server" ID="txtCustomer_ID"></ext:Hidden>
                                <ext:TextField ID="txtCustomer" runat="server" FieldLabel="Mã khách hàng:" ReadOnly="True" FieldCls="readonly" Width="222" Margins="0 5 0 0" />
                                <ext:Button runat="server" ID="btnAddCusWindows" ToolTip="Thêm khách hàng" Text="..." Margins="0 20 0 0">
                                    <DirectEvents>
                                        <Click OnEvent="btnCustomer_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:TextField ID="txtCustomer_Address" runat="server" FieldLabel="Địa chỉ:" ReadOnly="True" FieldCls="readonly" Width="520" Margins="0 20 0 0" />
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer ID="FieldContainer6"
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtCustomer_Name" runat="server" FieldLabel="Tên khách hàng:" ReadOnly="True" FieldCls="readonly" Width="250" Margins="0 20 0 0" />
                                <ext:TextField ID="txtCustomer_Contact" runat="server" FieldLabel="Liên hệ Ông/Bà:" ReadOnly="True" FieldCls="readonly" Width="250" Margins="0 20 0 0" />
                                <ext:TextField ID="txtCustomer_Job" runat="server" FieldLabel="Chức vụ:" ReadOnly="True" FieldCls="readonly" Width="250" />
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer ID="FieldContainer4"
                            runat="server"
                            AnchorHorizontal="100%">
                            <Items>
                                <ext:GridPanel
                                    ID="grQuotesMaterials"
                                    Cls="grid-double"
                                    runat="server"
                                    EnableColumnMove="true"
                                    AutoWidth="true"
                                    AutoScroll="true"
                                    Layout="Fit"
                                    Height="215">
                                    <Store>
                                        <ext:Store
                                            ID="StoreQuotesMaterials"
                                            runat="server"
                                            OnReadData="StoreQuotesMaterials_RefreshData">
                                            <Model>
                                                <ext:Model ID="ModelQuotesMaterials" runat="server" IDProperty="Quotes_Materials_ID">
                                                    <Fields>
                                                        <ext:ModelField Name="Materials_Id" Type="Int" />
                                                        <ext:ModelField Name="Materials_Alias" Type="String" />
                                                        <ext:ModelField Name="Materials_Name" Type="String" />
                                                        <ext:ModelField Name="Unit_Name" Type="String" />
                                                        <ext:ModelField Name="Quotes_Product_Quantity" Type="Int" />
                                                        <ext:ModelField Name="Quotes_Product_Price" Type="Float" />
                                                        <ext:ModelField Name="Quotes_Product_VAT_Percent" Type="Float" />
                                                        <ext:ModelField Name="Quotes_Product_VAT" Type="Float" />
                                                        <ext:ModelField Name="Quotes_Product_TotalCash" Type="Float" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <ColumnModel runat="server">
                                        <Columns>
                                            <ext:RowNumbererColumn ID="RowNumbererColumn2" runat="server" Width="30" Align="Center" />
                                            <ext:Column ID="Column1" runat="server" Text="Mã hàng" Width="80" DataIndex="Materials_Alias"></ext:Column>
                                            <ext:Column ID="Column5" runat="server" Text="Tên hàng" Width="100" DataIndex="Materials_Name"></ext:Column>
                                            <ext:Column ID="Column6" runat="server" Text="Đơn vị tính" Width="90" DataIndex="Unit_Name"></ext:Column>
                                            <ext:Column ID="Column12" runat="server" Text="Số lượng" Width="90" DataIndex="Quotes_Product_Quantity">
                                                <Editor>
                                                    <ext:NumberField runat="server"></ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:Column ID="Column9" runat="server" AllowBlank="false" MinValue="0" Text="Đơn giá" Width="90" DataIndex="Quotes_Product_Price">
                                                <Renderer Handler="return indMoney(value);" />
                                                <Editor>
                                                    <ext:NumberField runat="server" AllowBlank="false" MinValue="0"></ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:Column ID="Column10" runat="server" Text="% VAT" Width="90" DataIndex="Quotes_Product_VAT_Percent">
                                                <Renderer Handler="return indMoney(value);" />
                                                <Editor>
                                                    <ext:NumberField runat="server" AllowBlank="false" MinValue="0"></ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:Column ID="Column11" runat="server" Text="VAT" Width="90" DataIndex="Quotes_Product_VAT">
                                                <Renderer Handler="return indMoney(record.data.Quotes_Product_Quantity * record.data.Quotes_Product_Price * record.data.Quotes_Product_VAT_Percent / 100);" />
                                            </ext:Column>
                                            <ext:Column ID="Column8" runat="server" Text="Thành tiền" Width="100" DataIndex="Quotes_Product_TotalCash" Flex="1">
                                                <Renderer Handler="return indMoney(record.data.Quotes_Product_Quantity * record.data.Quotes_Product_Price);" />
                                            </ext:Column>
                                        </Columns>
                                    </ColumnModel>
                                    <Plugins>
                                        <ext:RowEditing runat="server">
                                            <DirectEvents>
                                                <Edit OnEvent="UpdateMaterials_Click">
                                                    <ExtraParams>
                                                        <ext:Parameter Name="Quotes_Materials" Value="Ext.encode(#{grQuotesMaterials}.getRowsValues({selectedOnly : true}))" Mode="Raw" />
                                                    </ExtraParams>
                                                </Edit>
                                            </DirectEvents>
                                        </ext:RowEditing>
                                    </Plugins>
                                    <SelectionModel>
                                        <ext:CheckboxSelectionModel runat="server" Mode="Multi" />
                                    </SelectionModel>
                                </ext:GridPanel>
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer ID="FieldContainer3"
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:GridPanel
                                    ID="grQuotesProvision"
                                    Cls="grid-double"
                                    runat="server"
                                    EnableColumnMove="true"
                                    Width="518"
                                    Height="139"
                                    Layout="Fit"
                                    Margins="0 20 0 0">
                                    <Store>
                                        <ext:Store
                                            ID="StoreQuotesProvision"
                                            runat="server"
                                            OnReadData="StoreQuotesProvision_RefreshData">
                                            <Model>
                                                <ext:Model ID="ModelQuotesProvision" runat="server" IDProperty="Quotes_Provision_Id" Name="Provision">
                                                    <Fields>
                                                        <ext:ModelField Name="Quotes_Provision_Id" Type="Int" UseNull="true" />
                                                        <ext:ModelField Name="Quotes_Provision_Name" Type="String" />
                                                        <ext:ModelField Name="Quotes_Provision_Value" Type="String" />
                                                        <ext:ModelField Name="Quotes_ID" Type="Int" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <Plugins>
                                        <ext:CellEditing runat="server" ClicksToEdit="1" />
                                    </Plugins>
                                    <ColumnModel runat="server">
                                        <Columns>
                                            <ext:Column ID="Column13" runat="server" Text="Điều khoản" Width="200" DataIndex="Quotes_Provision_Name">
                                                <Editor>
                                                    <ext:TextField ID="txtQuotes_Provision_Name" runat="server" AllowBlank="false" />
                                                </Editor>
                                            </ext:Column>
                                            <ext:Column ID="Column20" runat="server" Text="Nội dung" Width="318" DataIndex="Quotes_Provision_Value" Flex="1">
                                                <Editor>
                                                    <ext:TextField ID="txtQuotes_Provision_Value" runat="server" AllowBlank="false" />
                                                </Editor>
                                            </ext:Column>
                                            <ext:ImageCommandColumn runat="server" Width="30" Sortable="false">
                                                <Commands>
                                                    <ext:ImageCommand Icon="Decline" ToolTip-Text="Xóa" CommandName="delete">
                                                    </ext:ImageCommand>
                                                </Commands>
                                                <Listeners>
                                                    <Command Handler="this.up('gridpanel').store.removeAt(recordIndex);" />
                                                </Listeners>
                                            </ext:ImageCommandColumn>
                                        </Columns>
                                    </ColumnModel>
                                    <Buttons>
                                        <ext:Button runat="server" Text="Thêm điều khoản" Icon="Add">
                                            <Listeners>
                                                <Click Handler="#{StoreQuotesProvision}.insert(#{StoreQuotesProvision}.getCount(), {}); #{grQuotesProvision}.editingPlugin.startEditByPosition({row:#{StoreQuotesProvision}.getCount()-1, column:0});" />
                                            </Listeners>
                                        </ext:Button>
                                        <ext:Button ID="Button1" runat="server" Text="Hủy bỏ" Icon="ArrowRotateClockwise">
                                            <Listeners>
                                                <Click Handler="#{StoreQuotesProvision}.load();" />
                                            </Listeners>
                                        </ext:Button>
                                    </Buttons>
                                </ext:GridPanel>
                                <ext:FieldContainer runat="server"
                                    AnchorHorizontal="100%">
                                    <Items>
                                        <ext:TextField ID="txtSumPrice" runat="server" FieldLabel="Tổng tiền hàng:" ClientIDMode="Static" ReadOnly="True" FieldCls="readonly" Text="0" MaskRe="/[0-9\.]/" AnchorHorizontal="100%">
                                            <Listeners>
                                                <Change Fn="NumCheck" />
                                            </Listeners>
                                        </ext:TextField>
                                        <ext:TextField ID="txtSumVAT" runat="server" FieldLabel="Tổng tiền VAT:" ClientIDMode="Static" ReadOnly="True" FieldCls="readonly" Text="0" MaskRe="/[0-9\.]/" AnchorHorizontal="100%">
                                            <Listeners>
                                                <Change Fn="NumCheck" />
                                            </Listeners>
                                        </ext:TextField>
                                        <ext:TextField ID="txtShippingFee" runat="server" FieldLabel="Phí vận chuyển:" ClientIDMode="Static" AllowBlank="False" Text="0" MaskRe="/[0-9\.]/" AnchorHorizontal="100%">
                                            <Listeners>
                                                <Change Fn="NumCheck" />
                                            </Listeners>
                                        </ext:TextField>
                                        <ext:TextField ID="txtSumTotalCash" runat="server" FieldLabel="Tổng cộng:" ClientIDMode="Static" ReadOnly="True" FieldCls="readonly" Text="0" MaskRe="/[0-9\.]/" AnchorHorizontal="100%">
                                            <Listeners>
                                                <Change Handler="this.setValue(Ext.util.Format.number(newValue.replace(/[\,\.]/g, ''), '0.000/i').replace(/[.]/g, ','));" />
                                            </Listeners>
                                        </ext:TextField>
                                        <ext:FieldContainer runat="server" Layout="HBox">
                                            <Items>
                                                <ext:ComboBox runat="server"
                                                    ID="cbCurrency"
                                                    QueryMode="Local"
                                                    SelectOnFocus="true"
                                                    ForceSelection="True"
                                                    FieldLabel="Loại tiền"
                                                    DisplayField="Currency_Name"
                                                    ValueField="Currency_ID"
                                                    EmptyText="Chọn loại tiền"
                                                    AllowBlank="false"
                                                    Width="225"
                                                    ContextMenuID="cbCurrencyContext" MarginSpec="0 5 0 0">
                                                    <Store>
                                                        <ext:Store runat="server" ID="CurrencyStore" OnReadData="ReloadComboBox">
                                                            <Model>
                                                                <ext:Model ID="CurrencyModel" runat="server" IDProperty="Currency_ID">
                                                                    <Fields>
                                                                        <ext:ModelField Name="Currency_Name" Type="String" />
                                                                    </Fields>
                                                                </ext:Model>
                                                            </Model>
                                                        </ext:Store>
                                                    </Store>
                                                </ext:ComboBox>
                                                <ext:Button runat="server" Icon="Add">
                                                    <Listeners>
                                                        <Click Handler="#{WindowsCurrency}.show();"></Click>
                                                    </Listeners>
                                                    <ToolTips>
                                                        <ext:ToolTip runat="server" Html="Thêm mới tiền tệ" />
                                                    </ToolTips>
                                                </ext:Button>
                                            </Items>
                                        </ext:FieldContainer>
                                    </Items>
                                </ext:FieldContainer>
                            </Items>
                        </ext:FieldContainer>
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Window>
        <%--------------Material-----------------%>
        <ext:Window ID="WindowMaterials" runat="server"
            Title="Thông tin vật tư"
            DefaultAnchor="100%"
            Width="829"
            Height="400"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            Layout="Fit"
            HideMode="Offsets"
            Constrain="True">
            <Content>
                <ext:GridPanel
                    ID="grMaterials"
                    Border="True"
                    runat="server"
                    AutoWidth="true"
                    AutoScroll="true"
                    Cls="gird"
                    EnableColumnMove="true">
                    <Store>
                        <ext:Store
                            ID="StoreMaterials"
                            runat="server"
                            OnReadData="StoreMaterials_RefreshData"
                            PageSize="10">
                            <Model>
                                <ext:Model ID="Model1" runat="server" IDProperty="Materials_Id">
                                    <Fields>
                                        <ext:ModelField Name="Rows_ID" Type="Int" />
                                        <ext:ModelField Name="Materials_Alias" Type="String" />
                                        <ext:ModelField Name="Materials_Name" Type="String" />
                                        <ext:ModelField Name="Materials_Type_Name" Type="String" />
                                        <ext:ModelField Name="Unit_Name" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:Column ID="Column19" runat="server" Text="STT" Width="35" DataIndex="Rows_ID" Align="Center"></ext:Column>
                            <ext:Column ID="Column14" runat="server" Text="ID" Width="15" DataIndex="Materials_Id" Visible="false"></ext:Column>
                            <ext:Column ID="Column21" runat="server" Text="Mã vật tư" Width="100" DataIndex="Materials_Alias" Align="Left"></ext:Column>
                            <ext:Column ID="Column22" runat="server" Text="Tên vật tư" Width="200" DataIndex="Materials_Name" Align="Left"></ext:Column>
                            <ext:Column ID="Column23" runat="server" Text="Loại vật tư" Width="200" DataIndex="Materials_Type_Name" Align="Left"></ext:Column>
                            <ext:Column ID="Column24" runat="server" Text="Đơn vị tính" Width="200" DataIndex="Unit_Name" Align="Center" Flex="1"></ext:Column>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" Mode="Multi" />
                    </SelectionModel>
                    <TopBar>
                        <ext:Toolbar ID="Toolbar3" runat="server">
                            <Items>
                                <ext:Button ID="btnSelectMaterials" runat="server" Text="Chọn vật tư" Icon="Accept" ToolTip="Chọn vật tư">
                                    <DirectEvents>
                                        <Click OnEvent="btnSelectMaterials_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <DockedItems>
                        <ext:Toolbar ID="ToolBarMaterials" runat="server" Dock="Bottom" AnchorHorizontal="100%">
                            <Items>
                                <ext:TriggerField ID="txtSearchMaterials" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Search" />
                                    </Triggers>
                                    <DirectEvents>
                                        <TriggerClick OnEvent="SearchMaterials_Event"></TriggerClick>
                                        <KeyPress OnEvent="SearchMaterials_Event"></KeyPress>
                                        <KeyUp OnEvent="SearchMaterials_Event"></KeyUp>
                                    </DirectEvents>
                                </ext:TriggerField>
                                <ext:PagingToolbar ID="PagingToolbar4" runat="server" StoreID="StoreMaterials" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:GridPanel>
            </Content>
        </ext:Window>
        <%--------------Customer-----------------%>
        <ext:Window ID="WindowQuotesCustomer" runat="server"
            Title="Thông tin khách hàng"
            DefaultAnchor="100%"
            Width="829"
            Height="400"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            Layout="Fit"
            HideMode="Offsets">
            <Content>
                <ext:GridPanel
                    ID="grQuotesCustomer"
                    Border="True"
                    runat="server"
                    AutoWidth="true"
                    AutoScroll="true"
                    Cls="gird"
                    EnableColumnMove="true">
                    <Store>
                        <%--------------StoreQuotesCustomer-----------------%>
                        <ext:Store
                            ID="StoreQuotesCustomer"
                            runat="server"
                            OnReadData="StoreQuotesCustomer_RefreshData"
                            PageSize="10">
                            <Model>
                                <ext:Model ID="Model5" runat="server" IDProperty="Customer_ID">
                                    <Fields>
                                        <ext:ModelField Name="Rows_ID" Type="Int" />
                                        <ext:ModelField Name="Customer_Alias" Type="String" />
                                        <ext:ModelField Name="Customer_Name" Type="String" />
                                        <ext:ModelField Name="Materials_Name" Type="String" />
                                        <ext:ModelField Name="Customer_Phone1" Type="String" />
                                        <ext:ModelField Name="Contact_Email" Type="String" />
                                        <ext:ModelField Name="Customer_Account_Number" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:Column ID="Column15" runat="server" Text="STT" Width="35" DataIndex="Rows_ID" Locked="True" Align="Center"></ext:Column>
                            <ext:Column ID="Column16" runat="server" Text="ID" Width="15" DataIndex="Customer_ID" Visible="false"></ext:Column>
                            <ext:Column ID="Column17" runat="server" Text="Mã khách hàng" Width="100" DataIndex="Customer_Alias" Locked="True"></ext:Column>
                            <ext:Column ID="Column18" runat="server" Text="Tên khách hàng" Width="200" DataIndex="Customer_Name" Locked="True" Align="Left"></ext:Column>
                            <ext:Column ID="Column25" runat="server" Text="Số điện thoại" Width="100" DataIndex="Customer_Phone1" Align="Right"></ext:Column>
                            <ext:Column ID="Column26" runat="server" Text="Email" Width="200" DataIndex="Contact_Email" Align="Right"></ext:Column>
                            <ext:Column ID="Column27" runat="server" Text="Số tài khoản" Width="100" DataIndex="Customer_Account_Number" Align="Right" Flex="1"></ext:Column>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CellSelectionModel ID="CellSelectionModel2" runat="server">
                            <DirectEvents>
                                <Select OnEvent="CellQuotesCustomer_Click">
                                    <ExtraParams>
                                        <ext:Parameter Name="Customer_ID" Value="record.data.Customer_ID" Mode="Raw" />
                                    </ExtraParams>
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Select>
                            </DirectEvents>
                        </ext:CellSelectionModel>
                    </SelectionModel>
                    <DockedItems>
                        <ext:Toolbar ID="ToolBarQuotesCustomer" runat="server" Dock="Bottom" AnchorHorizontal="100%">
                            <Items>
                                <ext:TriggerField ID="txtSearchQuotesCustomer" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Search" />
                                    </Triggers>
                                    <DirectEvents>
                                        <TriggerClick OnEvent="SearchQuotesCustomer_Event"></TriggerClick>
                                        <KeyPress OnEvent="SearchQuotesCustomer_Event"></KeyPress>
                                        <KeyUp OnEvent="SearchQuotesCustomer_Event"></KeyUp>
                                    </DirectEvents>
                                </ext:TriggerField>
                                <ext:PagingToolbar ID="PagingToolbarQuotesCustomer" runat="server" StoreID="StoreQuotesCustomer" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:GridPanel>
            </Content>
        </ext:Window>
        <ext:Menu runat="server" ID="cbCurrencyContext">
            <Items>
                <ext:Button ID="Button3" runat="server" Text="Tải lại" Icon="DatabaseRefresh" Flat="True">
                    <Listeners>
                        <Click Handler="#{cbCurrency}.clearValue(); #{CurrencyStore}.reload(); #{cbCurrencyContext}.hide();"></Click>
                    </Listeners>
                </ext:Button>
            </Items>
        </ext:Menu>
    </Content>
</ext:Panel>